From 97b8e4d4c2b5100b2294f867d6eca447d9ca2c42 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 20 Oct 2025 15:35:24 -0400 Subject: [PATCH] Support ssh remotes with '#' and '?' in the path to the repository The same way git does. Affected repository types are regular git ssh remotes, and also gcrypt remotes, and potentially also bup remotes. repoPath is used for such repositories accessed over ssh. uriPath is used in some other places, eg the bittorrent special remote, where it would not be appropriate to mimic git's behavior. The distinction seems to hold up well from what I can see. The ordering of uriFragment after uriQuery is to correctly handle cases where both appear in an url. "ssh://localhost/tmp/foo?baz#bar" has an uriFragment of "#bar" and an uriQuery of "?baz". On the other hand, "ssh://localhost/tmp/foo#baz?bar" has an uriFragment of "#baz?bar" and no uriQuery. Sponsored-by: Dartmouth College's DANDI project --- CHANGELOG | 7 +++++++ Git.hs | 7 +++++-- ...o_discover_uuid_over_ssh_with___35___in_path_.mdwn | 2 ++ ...omment_1_00c1062abe02a42cea491f6bb8e6e5dc._comment | 11 +++++++++++ 4 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 doc/bugs/fails_to_discover_uuid_over_ssh_with___35___in_path_/comment_1_00c1062abe02a42cea491f6bb8e6e5dc._comment diff --git a/CHANGELOG b/CHANGELOG index c9eabe919c..21888c75f1 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,10 @@ +git-annex (10.20250930) UNRELEASED; urgency=medium + + * Support ssh remotes with '#' and '?' in the path to the repository, + the same way git does. + + -- Joey Hess Mon, 20 Oct 2025 15:22:30 -0400 + git-annex (10.20250929) upstream; urgency=medium * enableremote: Allow type= to be provided when it does not change the diff --git a/Git.hs b/Git.hs index 3eafcd674b..30930c2c17 100644 --- a/Git.hs +++ b/Git.hs @@ -38,7 +38,7 @@ module Git ( relPath, ) where -import Network.URI (uriPath, uriScheme, unEscapeString) +import Network.URI (uriPath, uriScheme, uriQuery, uriFragment, unEscapeString) #ifndef mingw32_HOST_OS import System.Posix.Files #endif @@ -73,7 +73,10 @@ repoLocation Repo { location = Unknown } = giveup "unknown repoLocation" - it's the gitdir, and for URL repositories, is the path on the remote - host. -} repoPath :: Repo -> OsPath -repoPath Repo { location = Url u } = toOsPath $ unEscapeString $ uriPath u +repoPath Repo { location = Url u } = toOsPath $ unEscapeString $ + -- git allows the path of a ssh url to include both '?' and '#', + -- and treats them as part of the path + uriPath u ++ uriQuery u ++ uriFragment u repoPath Repo { location = Local { worktree = Just d } } = d repoPath Repo { location = Local { gitdir = d } } = d repoPath Repo { location = LocalUnknown dir } = dir diff --git a/doc/bugs/fails_to_discover_uuid_over_ssh_with___35___in_path_.mdwn b/doc/bugs/fails_to_discover_uuid_over_ssh_with___35___in_path_.mdwn index bd5130b64f..1b3ebda7eb 100644 --- a/doc/bugs/fails_to_discover_uuid_over_ssh_with___35___in_path_.mdwn +++ b/doc/bugs/fails_to_discover_uuid_over_ssh_with___35___in_path_.mdwn @@ -72,3 +72,5 @@ FTR: I was trying to backup some old behavioral videos (octopus) from the laptop [[!meta author=yoh]] [[!tag projects/dandi]] + +> [[fixed|done]] --[[Joey]] diff --git a/doc/bugs/fails_to_discover_uuid_over_ssh_with___35___in_path_/comment_1_00c1062abe02a42cea491f6bb8e6e5dc._comment b/doc/bugs/fails_to_discover_uuid_over_ssh_with___35___in_path_/comment_1_00c1062abe02a42cea491f6bb8e6e5dc._comment new file mode 100644 index 0000000000..f035f5644d --- /dev/null +++ b/doc/bugs/fails_to_discover_uuid_over_ssh_with___35___in_path_/comment_1_00c1062abe02a42cea491f6bb8e6e5dc._comment @@ -0,0 +1,11 @@ +[[!comment format=mdwn + username="joey" + subject="""comment 1""" + date="2025-10-20T19:16:15Z" + content=""" +Also affected is '?' in the path. It's somewhat surprising to me that git +treats these parts of an url as path components, but +not too surprising, as git's definition of "url" is pretty loose. + +Fixed git-annex to follow suite. +"""]] -- 2.30.2